package gamedemo.component.movement;

import gamedemo.component.ComponentException;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;

public class PlayerMovementComponent extends MovementComponent {

	@Override
	public void update(GameContainer gc, StateBasedGame sb, int delta) {
		resetAcceleration();
		Input input = gc.getInput();
		
		if(input.isKeyDown(Input.KEY_LEFT)) {
			moveLeft(delta);
		}
		
		if(input.isKeyDown(Input.KEY_RIGHT)) {
			moveRight(delta);
		}
		
		if(input.isKeyDown(Input.KEY_SPACE) || input.isKeyDown(Input.KEY_X)) {
			jump(delta);
		}
		
		if(input.isKeyDown(Input.KEY_UP)) {
			moveUp(delta);
		}
		
		if(input.isKeyDown(Input.KEY_DOWN)){
			moveDown(delta);
		}		
		
		updateStuff(GROUND_FRICTION, GRAVITY, delta);
	}

	@Override
	public void init() throws ComponentException {
		// DO NOTHING
	}
}
